package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.ChanPinDaoImpl;
import com.ysd.dao.impl.ChanPinXiLieDaoImpl;
import com.ysd.dao.impl.ChanPinXiangQingDaoImpl;
import com.ysd.entity.ChanPin;
import com.ysd.entity.ChanPinXiLie;
import com.ysd.entity.ChanPinXiangQing;

public class ProductsServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ChanPinXiLieDaoImpl cpxlDao = new ChanPinXiLieDaoImpl();
		List<ChanPinXiLie> cpxlList = cpxlDao.getChanPinXiLieList();
		request.setAttribute("cpxlList", cpxlList);

		// 根据产品分类Id查询对应的产品
		// 接受前台传来的参数
		int cpId = Integer.parseInt(request.getParameter("waiJianId"));
		ChanPinDaoImpl cpDao = new ChanPinDaoImpl();
		List<ChanPin> chanpinList = cpDao.getChanPinList(cpId);
		request.setAttribute("chanpinList", chanpinList);
		
		
		
		
		
		request.getRequestDispatcher("productlist.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
